home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / borland / tpwn31.zip / PASCAL.ZIP / PENWIN.PAS < prev    next >
Pascal/Delphi Source File  |  1992-04-06  |  35KB  |  1,166 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       Turbo Pascal for Windows Run-time Library       }
  4. {       Windows 3.1 API Interface Unit                  }
  5. {       Pen Windows Interface unit                      }
  6. {                                                       }
  7. {       Copyright (c) 1992 Borland International        }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit PenWin;
  12.  
  13. {$S-}
  14.  
  15. interface
  16.  
  17. uses WinTypes, WinProcs, Win31;
  18.  
  19. {***** General Pen Windows Definitions ************************************}
  20. type
  21.   TRec = Integer;
  22.   PSYV = ^TSYV;
  23.   TSYV = Longint;
  24.   THRec = THandle;
  25.   TCL = Integer;
  26.   TALC = Longint;
  27.   THKP = Word;
  28.  
  29. type
  30.   TDF = function(dirq: Integer; InP, OutP: Pointer; Max: Integer;
  31.     Context, Data : Longint): Integer;
  32.  
  33. const
  34.   BitPenup               = $8000;
  35.  
  36. function FPenUp(X: LongInt): Boolean;
  37. inline(
  38.   $58/          { POP     AX }
  39.   $5A/          { POP     DX }
  40.   $2D/$00/$80/  { SUB     AX,8000H }
  41.   $1B/$C0/      { SBB     AX,AX }
  42.   $40);         { INC     AX }
  43.  
  44. { Default pen cursor to indicate writing, points northwest }
  45. const
  46.  IDC_Pen           = MakeIntResource(32631);
  47.  
  48. { alternate select cursor: upsidedown standard arrow, points southeast }
  49. const
  50.   IDC_AltSelect    = MakeIntResource(32501);
  51.  
  52. const
  53.   rc_WDefault            = $FFFF;
  54.   rc_Ldefault            = $FFFFFFFF;
  55.   rc_WDefaultFlags       = $8000;
  56.   rc_LDefaultFlags       = $80000000;
  57.  
  58. { HIWORD(SYV) defines and detection macros }
  59.  
  60. const
  61.   syvhi_Special          = 0;
  62.   syvhi_ANSI             = 1;
  63.   syvhi_Gesture          = 2;
  64.   syvhi_Kanji            = 3;
  65.   syvhi_Shape            = 4;
  66.   syvhi_UniCode          = 5;
  67.   syvhi_VKey             = 6;
  68.  
  69. function FIsSpecial(syv: TSYV): Boolean;
  70. function FIsAnsi(syv: TSYV): Boolean;
  71. function FIsGesture(syv: TSYV): Boolean;
  72. function FIsKanji(syv: TSYV): Boolean;
  73. function FIsShape(syv: TSYV): Boolean;
  74. function FIsUniCode(syv: TSYV): Boolean;
  75. function FIsVKey(syv: TSYV): Boolean;
  76.  
  77.  
  78. { Macros to convert between SYV and ANSI }
  79. function ChSyvToAnsi(syv: TSYV): Byte;
  80. function SyvCharacterToSymbol(c: Char): TSYV;
  81. function SyvKanjiToSymbol(c: Char): TSYV;
  82.  
  83. { SYV values with special meanings to Pen Windows }
  84.  
  85. const
  86.   syv_Null               = $00000000;
  87.   syv_Unknown            = $00000001;
  88.   syv_Empty              = $00000003;
  89.   syv_BeginOr            = $00000010;
  90.   syv_EndOr              = $00000011;
  91.   syv_Or                 = $00000012;
  92.   syv_SoftNewLine        = $00000020;
  93.   syv_SpaceNull          = $00010000;
  94.  
  95. { SYV values for gestures (map into UNICODE space) }
  96.  
  97. const
  98.   syv_KKConvert          = $0002FFD4;
  99.   syv_Clear              = $0002FFD5;
  100.   syv_ExtendSelect       = $0002FFD8;
  101.   syv_Undo               = $0002FFD9;
  102.   syv_Copy               = $0002FFDA;
  103.   syv_Cut                = $0002FFDB;
  104.   syv_Paste              = $0002FFDC;
  105.   syv_ClearWord          = $0002FFDD;
  106.   syv_User               = $0002FFDE;  { Reserved }
  107.   syv_Correct            = $0002FFDF;
  108.  
  109.   syv_Backspace          = $00020008;
  110.   syv_Tab                = $00020009;
  111.   syv_Return             = $0002000D;
  112.   syv_Space              = $00020020;
  113.  
  114.  
  115. function FIsStdGesture(syv: TSYV): Boolean;
  116. function FIsAnsiGesture(syv: TSYV): Boolean;
  117.  
  118.  
  119. { Application specific gestures, Circle a-z and Circle A-Z }
  120. const
  121.   syv_AppGestureMask     = $00020000;
  122.   syv_CircleUpA          = $000224B6;
  123.   syv_CircleUpZ          = $000224CF;
  124.   syv_CircleLoA          = $000224D0;
  125.   syv_CircleLoZ          = $000224E9;
  126.  
  127. { Gesture Macros }
  128.  
  129. function FIsLoAppGesture(syv: TSYV): Boolean;
  130. function FIsUpAppGesture(syv: TSYV): Boolean;
  131. function FIsAppGesture(syv: TSYV): Boolean;
  132.  
  133. function SyvAppGestureFromLoAnsi(Ansi: Char): TSYV;
  134. function SyvAppGestureFromUpAnsi(Ansi: Char): TSYV;
  135. function AnsiFromSyvAppGesture(syv: TSYV): Byte;
  136.  
  137.  
  138.  
  139. { SYV definitions for shapes }
  140.  
  141. const
  142.   syv_ShapeLine          = $00040001;
  143.   syv_ShapeEllipse       = $00040002;
  144.   syv_ShapeRect          = $00040003;
  145.   syv_ShapeMin           = syv_ShapeLine;
  146.   syv_ShapeMax           = syv_ShapeRect;
  147.  
  148. {***** Recognition Error Codes ********************************************}
  149. const
  150.   rec_OEM                = -1024;
  151.   rec_Language           = -48;
  152.   rec_Guide              = -47;
  153.   rec_ParamError         = -46;
  154.   rec_InvalidRef         = -45;
  155.   rec_RectExclude        = -44;
  156.   rec_RectBound          = -43;
  157.   rec_PCM                = -42;
  158.   rec_ResultMode         = -41;
  159.   rec_HWnd               = -40;
  160.   rec_ALC                = -39;
  161.   rec_ErrorLevel         = -38;
  162.   rec_CLVerify           = -37;
  163.   rec_Dict               = -36;
  164.   rec_HRec               = -35;
  165.   rec_BadEventRef        = -33;
  166.   rec_NoCollection       = -32;
  167.  
  168.   rec_Debug              = -32;
  169.  
  170.   rec_PointerEvent       = -31;
  171.   rec_BadHPenData        = -9;
  172.   rec_OOM                = -8;
  173.   rec_NoInput            = -7;
  174.   rec_NoTablet           = -6;
  175.   rec_Busy               = -5;
  176.   rec_BufferTooSmall     = -4;
  177.   rec_Abort              = -3;
  178.  
  179.   rec_Overflow           = -1;
  180.  
  181.   rec_OK                 = 0;
  182.   rec_TermBound          = 1;
  183.   rec_TermEx             = 2;
  184.   rec_TermPenUp          = 3;
  185.   rec_TermRange          = 4;
  186.   rec_TermTimeOut        = 5;
  187.   rec_Done               = 6;
  188.   rec_TermOEM            = 512;
  189.  
  190. {***** Pen Driver Structures and Entry points *****************************}
  191.  
  192. type
  193.   POEMPenInfo = ^TOEMPenInfo;
  194.   TOEMPenInfo = record
  195.     wPdt: Word;
  196.     wValueMax: Word;
  197.     wDistinct: Word;
  198.   end;
  199.  
  200. const
  201.   pdt_Null               = 0;
  202.   pdt_Pressure           = 1;
  203.   pdt_Height             = 2;
  204.   pdt_AngleXY            = 3;
  205.   pdt_AngleZ             = 4;
  206.   pdt_BarrelRotation     = 5;
  207.   pdt_OEMSpecific        = 16;
  208.  
  209.   MaxOEMDataWords        = 6;
  210.  
  211. type
  212.   PPenPacket = ^TPenPacket;
  213.   TPenPacket = record
  214.     wTabletX: Word;
  215.     wTabletY: Word;
  216.     wPDK: Word;
  217.     rgwOemData: array[0..MaxOEMDataWords - 1] of Word;
  218.   end;
  219.  
  220. type
  221.   TRawHook = function(PenPacket: PPenPacket): Bool;
  222.  
  223. type
  224.   PPenInfo = ^TPenInfo;
  225.   TPenInfo = record
  226.     cxRawWidth: Word;
  227.     cyRawHeight: Word;
  228.     wDistinctWidth: Word;
  229.     wDistinctHeight: Word;
  230.     nSamplingRate: Integer;
  231.     nSamplingDist: Integer;
  232.     lPdc: Longint;
  233.     cPens: Integer;
  234.     cbOemData: Integer;
  235.     rgoempeninfo: array[0..MaxOEMDataWords - 1] of TOEMPenInfo;
  236.     rgwReserved: array[0..7] of Word;
  237.   end;
  238.  
  239. const
  240.   pdc_Integrated         = $00000001;
  241.   pdc_Proximity          = $00000002;
  242.   pdc_Range              = $00000004;
  243.   pdc_Invert             = $00000008;
  244.   pdc_Relative           = $00000010;
  245.   pdc_Barrel1            = $00000020;
  246.   pdc_Barrel2            = $00000040;
  247.   pdc_Barrel3            = $00000080;
  248.  
  249. type
  250.   PStrokeInfo = ^TStrokeInfo;
  251.   TStrokeInfo = record
  252.     cPnt: Word;
  253.     cbPnts: Word;
  254.     wPDK: Word;
  255.     dwTick: Longint;
  256.   end;
  257.  
  258. type
  259.   PCalbStruct = ^TCalbStruct;
  260.   TCalbStruct = record
  261.     wOffsetX: Integer;
  262.     wOffsetY: Integer;
  263.     wDistinctWidth: Integer;
  264.     wDistinctHeight: Integer;
  265.   end;
  266.  
  267. {***** DRV_ values for pen driver specific messages ***********************}
  268.  
  269. const
  270.   drv_SetPenDriverEntryPoints    = drv_Reserved+1;
  271.   drv_RemovePenDriverEntryPoints = drv_Reserved+2;
  272.   drv_SetPenSamplingRate         = drv_Reserved+3;
  273.   drv_SetPenSamplingDist         = drv_Reserved+4;
  274.   drv_GetName                    = drv_Reserved+5;
  275.   drv_GetVersion                 = drv_Reserved+6;
  276.   drv_GetPenInfo                 = drv_Reserved+7;
  277.   drv_GetCalibration             = drv_Reserved+11;
  278.   drv_SetCalibration             = drv_Reserved+12;
  279.  
  280. procedure UpdatePenInfo(lpPenInfo: PPenInfo);
  281. function EndPenCollection(recEnd: TRec): Bool;
  282. function GetPenHwData(lpPnt: PPoint; lpvOemData: Pointer; cPntMax: Integer;
  283.   wTimeOut: Word; lpsi: PStrokeInfo): TRec;
  284. function GetPenHwEventData(wEventRefBeg: Word; wEventRefEnd: Word;
  285.   lpPnt: PPoint; lpvOemData: Pointer; cPntMax: Integer; lpsi: PStrokeInfo): TRec;
  286.  
  287. (*